// 用户相关的请求
// 一、导入axios
import axios from '@/utils/request'
// 二、导出请求方法
// 1.1 登录
export function postLogin(data) {
  return axios({
    method: 'post',
    url: '/v1_0/authorizations',
    data,
  })
}

// 1.2 关注用户
export function postFollowUser(userId) {
  return axios({
    method: 'post',
    url: '/v1_0/user/followings',
    data: {
      target: userId,
    },
  })
}

// 1.3 取消关注
export function delFollowUser(userId) {
  return axios({
    method: 'delete',
    url: `/v1_0/user/followings/${userId}`,
  })
}

// 1.4 获取用户自己的信息
export const getUserInfo = () => {
  return axios({
    method: 'get',
    url: '/v1_0/user',
  })
}

// 1.5 获取用户个人资料
export const getUserProfile = () => {
  return axios({
    method: 'get',
    url: '/v1_0/user/profile',
  })
}

// 1.6 修改用户个人资料
export const updateUserProfile = (userObj = {}) => {
  return axios({
    method: 'patch',
    url: '/v1_0/user/profile',
    data: userObj,
  })
}

// 1.6 编辑用户照片资料（头像、身份证照片）
export const updateUserPhoto = formData => {
  return axios({
    method: 'patch',
    url: '/v1_0/user/photo',
    data: formData,
  })
}
